<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('加班列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>所属组织：</label>
                                <input type="text" name="belongOrganization"/>
                            </li>
                            <li>
                                <label>加班日期：</label>
                                <input type="text" class="time-input" placeholder="请选择加班日期" name="overWorkDate"/>
                            </li>
                            <li>
                                <label>加班类型：</label>
                                <select name="overWorkType">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>申请日期：</label>
                                <input type="text" class="time-input" placeholder="请选择申请日期" name="applyDate"/>
                            </li>
                            <li>
                                <label>补偿方式：</label>
                                <select name="rewardType" th:with="type=${@dict.getType('sys_reward_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <!--<div class="btn-group-sm" id="toolbar" role="group">-->
                <!--<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:work:add">-->
                    <!--<i class="fa fa-user-plus"></i> 我要加班-->
                <!--</a>-->
            <!--</div>-->
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:work:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:work:remove')}]];
        var myDatas = [[${@dict.getType('sys_approval_status')}]];
        var overWorkTypeDatas = [[${@dict.getType('sys_over_work_type')}]];
        var rewardTypeDatas = [[${@dict.getType('sys_reward_type')}]];
        var prefix = ctx + "system/work";

        $(function() {
            var options = {
                url: prefix + "/myDeptWorkList",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "加班",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'overWorkId',
                    title: '加班id',
                    visible: false
                },
                {
                    field: 'userName',
                    title: '员工姓名'
                },
                {
                    field: 'deptId',
                    title: '部门编号'
                },
                {
                    field: 'belongOrganization',
                    title: '所属组织'
                },
                {
                    field: 'post',
                    title: '职位'
                },
                {
                    field: 'overWorkDate',
                    title: '加班日期'
                },
                {
                    field: 'overWorkType',
                    title: '加班类型',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(overWorkTypeDatas, value);
                    }
                },
                {
                    field: 'applyDate',
                    title: '申请日期'
                },
                {
                    field: 'beginTime',
                    title: '加班开始时间'
                },
                {
                    field: 'endTime',
                    title: '加班结束时间'
                },
                {
                    field: 'restTime',
                    title: '休息时长'
                },
                {
                    field: 'overWorkHour',
                    title: '加班小时数'
                },
                {
                    field: 'overWorkReason',
                    title: '加班原因'
                },
                {
                    field: 'rewardType',
                    title: '补偿方式',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(rewardTypeDatas, value);
                    }
                },
                {
                    field: 'remarks',
                    title: '备注'
                },
                {
                    field: 'workStatus',
                    title: '审批状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(myDatas, value);
                    }
                },
                {
                    field: 'userId',
                    title: '员工编号'
                },
                {
                    title: '操作',
                    align: 'center',
                    // formatter: function(value, row, index) {
                    //     var actions = [];
                    //     actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.overWorkId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                    //     actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.overWorkId + '\')"><i class="fa fa-remove"></i>删除</a>');
                    //     return actions.join('');
                    // }
                    formatter: function(value, row, index) {
                        var actions = [];
                        if (row.workStatus == 1){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.leaderApproval(\'' + row.overWorkId + '\')"><i class="fa fa-check-square-o"></i>通过审批</a> ');
                        }
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.overWorkId + '\')"><i class="fa fa-search"></i>详细</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });


        /* 用户管理-修改-选择部门树 */
        function selectDeptTree() {
            console.log("部门树")
            var deptId = $.common.isEmpty($("#treeId").val()) ? "100" : $("#treeId").val();
            $("#deptId").val(deptId);
            var url = ctx + "system/dept/selectDeptTree/" + deptId;
            var options = {
                title: '选择部门',
                width: "350",
                url: url,
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var tree = layero.find("iframe")[0].contentWindow.$._tree;
            var body = layer.getChildFrame('body', index);
            $("#treeId").val(body.find('#treeId').val());
            $("#treeName").val(body.find('#treeName').val());
            layer.close(index);
        }
    </script>
</body>
</html>